home *** CD-ROM | disk | FTP | other *** search
- class MoonStoneObstacle extends SideScroller.StaticObject
- {
- var nPercent;
- var bObjectBlock;
- var bObjectSpecial;
- var mcRef;
- function MoonStoneObstacle(__mcRef, __oLayer, _nPercent)
- {
- super(__mcRef,__oLayer);
- if(_nPercent == undefined)
- {
- _nPercent = 100;
- }
- this.nPercent = _nPercent;
- this.bObjectBlock = false;
- this.bObjectSpecial = true;
- this.setState("Idle");
- }
- function onHitSpecial(__oRef)
- {
- if(this.CurrentState == "Idle")
- {
- if(TakGround(__oRef).IsInHeadSwing)
- {
- this.ParentLayer.doAddListener(this);
- Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"ItemHit.mp3");
- if(Library.Utils.MoreMath.getRandomRange(1,100) < this.nPercent)
- {
- var _loc3_ = this.ParentLayer.doAttachVisual("Dynamic_MoonStone");
- _loc3_._x = this.Coord.x;
- _loc3_._y = this.Coord.y;
- _global.LevelManager.Instance.doAddMoonStone(_loc3_);
- }
- this.setState("Explode");
- this.doLockState();
- }
- }
- }
- function doDestroy()
- {
- this.ParentLayer.doRemoveListener(this);
- super.doDestroy();
- }
- function doExplode()
- {
- if(this.isStateComplete())
- {
- if(!this.mcRef.bStateAfterExplosion)
- {
- this.doDestroy();
- }
- else
- {
- this.doForcedSetState("ExplodedIdle");
- this.ParentLayer.doRemoveListener(this);
- }
- }
- }
- }
-